# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
  def img_tag file_name
      image_tag %[#{IMG_PATH}#{file_name}], :alt => " "
  end

  def point point
    point_s = point.to_s
    fushu = point_s.first == '-' ? true : false
    size = point_s.size - ( fushu ? 1 : 0 )
    if size <= 3
      point_s
    else
      str = ""
      point_s.delete('-').split('').each_with_index do |ch, i|
        str << "," if i > 0 && (size - i) % 3 == 0
        str << ch
      end
      fushu ? '-' + str : str
    end
  end

  def bili_video_link wid, name=nil
     link_to (name ? name : "av#{wid}"), "http://#{BILI_PATH}/video/av#{wid}/", :target => "_blank"
  end

  def bili_mylist_link mylist_id, name=nil
     link_to (name ? name : "mylist#{mylist_id}"), "http://#{BILI_PATH}/mylist#{mylist_id}", :target => "_blank"
  end
end
